/*
 * @author: sanbao
 * @Date: 2022-07-23 10:41:26
 */
import request from "@/utils/request";
/**
 * 
 * @param {页} pagenum 
 * @param {条} pagesize 
 * @param {关键字} data 
 * @returns 
 */
const getuserslist = (pagenum: number, pagesize: number, data = '') => {
    //  http: //47.108.251.106:8881/api/private/v1/users?query=&pagenum=1&pagesize=5
    return request({
        url: `users?query=${data}&pagenum=${pagenum}&pagesize=${pagesize}`,
        method: 'GET',
    })
}
/**
 * 删除
 * @param id 
 * @returns 
 */
const deleteuserlist = (id: number) => {
    return request({
        url: `users/${id}`,
        method: 'DELETE',
    })
}
/**
 * 修改状态
 * @param id 
 * @param state 
 * @returns 
 */
const putuserliststate = (id: number, state: boolean) => {
    return request({
        // http: //47.108.251.106:8881/api/private/v1/users/500/state/true
        url: `users/${id}/state/${state}`,
        method: 'PUT',
    })
}
/**
 * 添加
 * @param data 
 * @returns 
 */
const adduserslist = (data: object) => {
    return request({
        url: 'users',
        method: 'POST',
        data
    })
}
/**
 * 单个数据查询
 * @param id 
 * @returns 
 */
const finduserslist = (id: number) => {
    // http://47.108.251.106:8881/api/private/v1/users/500
    return request({
        url: `users/${id}`,
        method: 'GET',
    })
}
/**
 * 
 * @param id 
 * @param data 
 * @returns 
 */
const edituserlist = (id: number, data: object) => {
    return request({
        url: `users/${id}`,
        method: 'PUT',
        data
    })
}
//
const getroleslist = () => {
    // http://47.108.251.106:8881/api/private/v1/roles
    return request({
        url: 'roles',
        method: 'GET',
    })
}
export default {
    getuserslist,
    deleteuserlist,
    putuserliststate,
    adduserslist,
    finduserslist,
    edituserlist,
    getroleslist

}